<template>
  <header class="header">
    <h1>todos</h1>
    <input
      class="new-todo"
      placeholder="请输入任务名称"
      autofocus
      v-model="renderList"
      @keyup.enter="add"
    />
  </header>
</template>

<script>
export default {
  name: 'ToHeader',
  data () {
    return {
      renderList: ''
    }
  },
  methods: {
    add () {
      if (this.renderList.length === 0) return
      this.$emit('add', this.renderList)
      this.renderList = ''
    }
  }
}
</script>

<style scoped lang="less"></style>
